#include<stdio.h>
#include<stdlib.h>
struct Node{
	int data;
	struct Node *next;
};
void insertNode(struct Node *head,int x)
{
	struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
	newNode->data=x;
	newNode->next=NULL;
	struct Node *current=head;
	while(current->next!=NULL&&current->next->data<x)
	{
		current=current->next;
	}
	newNode->next=current->next;
	current->next=newNode;
}
int main()
{
	int n;
	scanf("%d",&n);
	struct Node *head=(struct Node*)malloc(sizeof(struct Node));
	head->next=NULL;
	for(int i=0;i<n;i++)
	{
		int data;
		scanf("%d",&data);
		insertNode(head,data);
	}
	int x;
	scanf("%d",&x);
	insertNode(head,x);
	struct Node *current=head->next;
	while(current!=NULL)
	{
		printf("%d ",current->data);
		current=current->next;
	}
	return 0;
}
